#ifndef COMMUNICATION_H
#define COMMUNICATION_H

#include "Arduino.h"
#include "CommunicationListener.h"
#include "Command.h"
#include "CRC.h"

#define NB_OF_SERIAL_COMMUNICATION      1

class Communication {
  public:
    
    /* Methodes */
	static Communication* add(Stream* serialPort, CommunicationListener* communucationListener);
    static void byteReceived(Stream* serialPort, byte byteReceived);
    void sendCommand(Command* command);
    /* Attributes */
	static Communication* m_communicationInstances[NB_OF_SERIAL_COMMUNICATION];
    
  private:
    /* Methodes */
	Communication(Stream* serialPort, CommunicationListener* communucationListener);  /* Constructor */
    void byteReceived(byte byteReceived);
    Stream* getStream();
    /* Attributes */
    int m_nbOfByte;
	Stream* m_serialPort;
    CommunicationListener* m_communucationListener;
    Command* m_commandToTransmit;
    Command* m_commandInReception;
    CRC* m_CRCInReception;
    
};

#endif /* COMMUNICATION_H */
